<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="cache-control" content="no-cache">
<title>Genivia - Thread and mutex functions</title>
<link href="genivia_tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="genivia_content.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="top">
 <div id="titlearea">
  <table height="72px" width="100%" cellspacing="0" cellpadding="0">
   <tbody>
    <tr>
     <td width="10%">&nbsp;</td>
     <td width="175px"><a href="https://www.genivia.com"><img alt="Genivia" src="GeniviaLogo2_trans_noslogan.png"/></a></td>
     <td class="tab_home"><a href="https://www.genivia.com">Home</a></td>
     <td class="tab_home"><a href="https://www.genivia.com/docs.html">Documentation</a></td>
     <td>
      <div style="float: right; font-size: 18px; font-weight: bold;">Thread and mutex functions</div>
      <br>
      <div style="float: right; font-size: 10px;">updated Tue Apr 20 2021 by Robert van Engelen</div>
     </td>
     <td width="10%">&nbsp;</td>
    </tr>
   </tbody>
  </table>
 </div>
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__threads.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a>  </div>
  <div class="headertitle">
<div class="title">Thread and mutex functions</div>  </div>
</div><!--header-->
<div class="contents">

<p>This module defines portable thread and mutex functions.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga53ca774b0fc84afe282a5419d2d7239a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a">THREAD_TYPE</a></td></tr>
<tr class="memdesc:ga53ca774b0fc84afe282a5419d2d7239a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Type of a thread (thread ID)  <a href="#ga53ca774b0fc84afe282a5419d2d7239a">More...</a><br /></td></tr>
<tr class="separator:ga53ca774b0fc84afe282a5419d2d7239a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9ab5a77b8cf2b98f7d6c1b48bb421f69"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga9ab5a77b8cf2b98f7d6c1b48bb421f69">THREAD_ID</a></td></tr>
<tr class="memdesc:ga9ab5a77b8cf2b98f7d6c1b48bb421f69"><td class="mdescLeft">&#160;</td><td class="mdescRight">The thread ID of self.  <a href="#ga9ab5a77b8cf2b98f7d6c1b48bb421f69">More...</a><br /></td></tr>
<tr class="separator:ga9ab5a77b8cf2b98f7d6c1b48bb421f69"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabee88cce937a2709b4799ed8df36d486"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486">THREAD_CREATE</a>(tidptr,  funcptr,  argptr)</td></tr>
<tr class="memdesc:gabee88cce937a2709b4799ed8df36d486"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a new thread.  <a href="#gabee88cce937a2709b4799ed8df36d486">More...</a><br /></td></tr>
<tr class="separator:gabee88cce937a2709b4799ed8df36d486"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga45fbba03f3933a43d2ed3819b53ec1c5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5">THREAD_CREATEX</a>(tidptr,  funcptr,  argptr)</td></tr>
<tr class="memdesc:ga45fbba03f3933a43d2ed3819b53ec1c5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a new joinable thread (Windows only)  <a href="#ga45fbba03f3933a43d2ed3819b53ec1c5">More...</a><br /></td></tr>
<tr class="separator:ga45fbba03f3933a43d2ed3819b53ec1c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga66800af53c229b4024b7d5e36e97eb1a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga66800af53c229b4024b7d5e36e97eb1a">THREAD_CLOSE</a>(tid)</td></tr>
<tr class="memdesc:ga66800af53c229b4024b7d5e36e97eb1a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Close the thread ID handle created by <code><a class="el" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5" title="Create a new joinable thread (Windows only) ">THREAD_CREATEX</a></code> (Windows only)  <a href="#ga66800af53c229b4024b7d5e36e97eb1a">More...</a><br /></td></tr>
<tr class="separator:ga66800af53c229b4024b7d5e36e97eb1a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5848fc7adb50b3a15e40955dce7f8f53"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga5848fc7adb50b3a15e40955dce7f8f53">THREAD_DETACH</a>(tid)</td></tr>
<tr class="memdesc:ga5848fc7adb50b3a15e40955dce7f8f53"><td class="mdescLeft">&#160;</td><td class="mdescRight">Detach a thread.  <a href="#ga5848fc7adb50b3a15e40955dce7f8f53">More...</a><br /></td></tr>
<tr class="separator:ga5848fc7adb50b3a15e40955dce7f8f53"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6bad18c2ce46fa43f1f4d83c8010a43b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga6bad18c2ce46fa43f1f4d83c8010a43b">THREAD_JOIN</a>(tid)</td></tr>
<tr class="memdesc:ga6bad18c2ce46fa43f1f4d83c8010a43b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Join a thread.  <a href="#ga6bad18c2ce46fa43f1f4d83c8010a43b">More...</a><br /></td></tr>
<tr class="separator:ga6bad18c2ce46fa43f1f4d83c8010a43b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae6cf42265fe26b84cec6c05b498a7b7c"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#gae6cf42265fe26b84cec6c05b498a7b7c">THREAD_EXIT</a></td></tr>
<tr class="memdesc:gae6cf42265fe26b84cec6c05b498a7b7c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Exit the current thread.  <a href="#gae6cf42265fe26b84cec6c05b498a7b7c">More...</a><br /></td></tr>
<tr class="separator:gae6cf42265fe26b84cec6c05b498a7b7c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab0733064c17124af0377d69e91d24430"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#gab0733064c17124af0377d69e91d24430">THREAD_CANCEL</a>(tid)</td></tr>
<tr class="memdesc:gab0733064c17124af0377d69e91d24430"><td class="mdescLeft">&#160;</td><td class="mdescRight">Cancel a thread.  <a href="#gab0733064c17124af0377d69e91d24430">More...</a><br /></td></tr>
<tr class="separator:gab0733064c17124af0377d69e91d24430"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga94ada48918e73511c91e3e0e885fe763"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763">MUTEX_TYPE</a></td></tr>
<tr class="memdesc:ga94ada48918e73511c91e3e0e885fe763"><td class="mdescLeft">&#160;</td><td class="mdescRight">Type of a mutex object.  <a href="#ga94ada48918e73511c91e3e0e885fe763">More...</a><br /></td></tr>
<tr class="separator:ga94ada48918e73511c91e3e0e885fe763"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga10ba6c8c4a5e2bcf9f5f5fd41675e122"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga10ba6c8c4a5e2bcf9f5f5fd41675e122">MUTEX_INITIALIZER</a></td></tr>
<tr class="memdesc:ga10ba6c8c4a5e2bcf9f5f5fd41675e122"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mutex initializer object.  <a href="#ga10ba6c8c4a5e2bcf9f5f5fd41675e122">More...</a><br /></td></tr>
<tr class="separator:ga10ba6c8c4a5e2bcf9f5f5fd41675e122"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaebadda8d216cdac28b0d9763be7fe689"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#gaebadda8d216cdac28b0d9763be7fe689">MUTEX_SETUP</a>(mx)</td></tr>
<tr class="memdesc:gaebadda8d216cdac28b0d9763be7fe689"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mutex object initialization.  <a href="#gaebadda8d216cdac28b0d9763be7fe689">More...</a><br /></td></tr>
<tr class="separator:gaebadda8d216cdac28b0d9763be7fe689"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga295d2586aa4d2379248805e622b43742"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga295d2586aa4d2379248805e622b43742">MUTEX_CLEANUP</a>(mx)</td></tr>
<tr class="memdesc:ga295d2586aa4d2379248805e622b43742"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mutex object finalization.  <a href="#ga295d2586aa4d2379248805e622b43742">More...</a><br /></td></tr>
<tr class="separator:ga295d2586aa4d2379248805e622b43742"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4a9fdd824c39252e5bf292df736e5648"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648">MUTEX_LOCK</a>(mx)</td></tr>
<tr class="memdesc:ga4a9fdd824c39252e5bf292df736e5648"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mutex object lock.  <a href="#ga4a9fdd824c39252e5bf292df736e5648">More...</a><br /></td></tr>
<tr class="separator:ga4a9fdd824c39252e5bf292df736e5648"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga706e720f96e7405766dd119e654e03f9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9">MUTEX_UNLOCK</a>(mx)</td></tr>
<tr class="memdesc:ga706e720f96e7405766dd119e654e03f9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mutex object unlock.  <a href="#ga706e720f96e7405766dd119e654e03f9">More...</a><br /></td></tr>
<tr class="separator:ga706e720f96e7405766dd119e654e03f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga889adb32271e98bd621f32a6bb9808b7"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga889adb32271e98bd621f32a6bb9808b7">COND_TYPE</a></td></tr>
<tr class="memdesc:ga889adb32271e98bd621f32a6bb9808b7"><td class="mdescLeft">&#160;</td><td class="mdescRight">The type of a condition variable.  <a href="#ga889adb32271e98bd621f32a6bb9808b7">More...</a><br /></td></tr>
<tr class="separator:ga889adb32271e98bd621f32a6bb9808b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga719d6c562837c107353b9e94d3668745"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga719d6c562837c107353b9e94d3668745">COND_SETUP</a>(cv)</td></tr>
<tr class="memdesc:ga719d6c562837c107353b9e94d3668745"><td class="mdescLeft">&#160;</td><td class="mdescRight">Condition variable initialization.  <a href="#ga719d6c562837c107353b9e94d3668745">More...</a><br /></td></tr>
<tr class="separator:ga719d6c562837c107353b9e94d3668745"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga59b186c1985a9361782b1a6d67cf8ef5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga59b186c1985a9361782b1a6d67cf8ef5">COND_CLEANUP</a>(cv)</td></tr>
<tr class="memdesc:ga59b186c1985a9361782b1a6d67cf8ef5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Condition variable finalization.  <a href="#ga59b186c1985a9361782b1a6d67cf8ef5">More...</a><br /></td></tr>
<tr class="separator:ga59b186c1985a9361782b1a6d67cf8ef5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaff925917acd5b6addbf1def943c302e4"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#gaff925917acd5b6addbf1def943c302e4">COND_SIGNAL</a>(cv)</td></tr>
<tr class="memdesc:gaff925917acd5b6addbf1def943c302e4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Condition variable signal operation.  <a href="#gaff925917acd5b6addbf1def943c302e4">More...</a><br /></td></tr>
<tr class="separator:gaff925917acd5b6addbf1def943c302e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga418ccb7a075721a1f6296ef1229c6ef2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__threads.html#ga418ccb7a075721a1f6296ef1229c6ef2">COND_WAIT</a>(mx,  cv)</td></tr>
<tr class="memdesc:ga418ccb7a075721a1f6296ef1229c6ef2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Condition variable wait operation.  <a href="#ga418ccb7a075721a1f6296ef1229c6ef2">More...</a><br /></td></tr>
<tr class="separator:ga418ccb7a075721a1f6296ef1229c6ef2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>This module defines portable thread and mutex functions. </p>
<ul>
<li><code><a class="el" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a" title="Type of a thread (thread ID) ">THREAD_TYPE</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga9ab5a77b8cf2b98f7d6c1b48bb421f69" title="The thread ID of self. ">THREAD_ID</a></code></li>
<li><code><a class="el" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486" title="Create a new thread. ">THREAD_CREATE(tidptr, funcptr, argptr)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5" title="Create a new joinable thread (Windows only) ">THREAD_CREATEX(tidptr, funcptr, argptr)</a></code> (for Windows)</li>
<li><code><a class="el" href="group__group__threads.html#ga66800af53c229b4024b7d5e36e97eb1a" title="Close the thread ID handle created by THREAD_CREATEX (Windows only) ">THREAD_CLOSE(tid)</a></code> (for Windows)</li>
<li><code><a class="el" href="group__group__threads.html#ga5848fc7adb50b3a15e40955dce7f8f53" title="Detach a thread. ">THREAD_DETACH(tid)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga6bad18c2ce46fa43f1f4d83c8010a43b" title="Join a thread. ">THREAD_JOIN(tid)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#gae6cf42265fe26b84cec6c05b498a7b7c" title="Exit the current thread. ">THREAD_EXIT</a></code></li>
<li><code><a class="el" href="group__group__threads.html#gab0733064c17124af0377d69e91d24430" title="Cancel a thread. ">THREAD_CANCEL(tid)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763" title="Type of a mutex object. ">MUTEX_TYPE</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga10ba6c8c4a5e2bcf9f5f5fd41675e122" title="Mutex initializer object. ">MUTEX_INITIALIZER</a></code></li>
<li><code><a class="el" href="group__group__threads.html#gaebadda8d216cdac28b0d9763be7fe689" title="Mutex object initialization. ">MUTEX_SETUP(mx)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga295d2586aa4d2379248805e622b43742" title="Mutex object finalization. ">MUTEX_CLEANUP(mx)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648" title="Mutex object lock. ">MUTEX_LOCK(mx)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9" title="Mutex object unlock. ">MUTEX_UNLOCK(mx)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga889adb32271e98bd621f32a6bb9808b7" title="The type of a condition variable. ">COND_TYPE</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga719d6c562837c107353b9e94d3668745" title="Condition variable initialization. ">COND_SETUP(cv)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga59b186c1985a9361782b1a6d67cf8ef5" title="Condition variable finalization. ">COND_CLEANUP(cv)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#gaff925917acd5b6addbf1def943c302e4" title="Condition variable signal operation. ">COND_SIGNAL(cv)</a></code></li>
<li><code><a class="el" href="group__group__threads.html#ga418ccb7a075721a1f6296ef1229c6ef2" title="Condition variable wait operation. ">COND_WAIT(mx, cv)</a></code> </li>
</ul>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga59b186c1985a9361782b1a6d67cf8ef5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COND_CLEANUP</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cv</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Condition variable finalization. </p>
<p>This macro finalizes the specified condition variable.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">cv</td><td><code><a class="el" href="group__group__threads.html#ga889adb32271e98bd621f32a6bb9808b7" title="The type of a condition variable. ">COND_TYPE</a></code> condition variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga719d6c562837c107353b9e94d3668745"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COND_SETUP</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cv</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Condition variable initialization. </p>
<p>This macro initializes the specified condition variable.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">cv</td><td><code><a class="el" href="group__group__threads.html#ga889adb32271e98bd621f32a6bb9808b7" title="The type of a condition variable. ">COND_TYPE</a></code> condition variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gaff925917acd5b6addbf1def943c302e4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COND_SIGNAL</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cv</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Condition variable signal operation. </p>
<p>This macro signals the specified condition variable.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">cv</td><td><code><a class="el" href="group__group__threads.html#ga889adb32271e98bd621f32a6bb9808b7" title="The type of a condition variable. ">COND_TYPE</a></code> condition variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga889adb32271e98bd621f32a6bb9808b7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COND_TYPE</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The type of a condition variable. </p>
<p>This macro represents a portable condition variable</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms. </dd></dl>

</div>
</div>
<a class="anchor" id="ga418ccb7a075721a1f6296ef1229c6ef2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COND_WAIT</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">mx, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cv&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Condition variable wait operation. </p>
<p>This macro waits on the specified condition variable and releases the mutex while waiting.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mx</td><td><code><a class="el" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763" title="Type of a mutex object. ">MUTEX_TYPE</a></code> mutex object </td></tr>
    <tr><td class="paramname">cv</td><td><code><a class="el" href="group__group__threads.html#ga889adb32271e98bd621f32a6bb9808b7" title="The type of a condition variable. ">COND_TYPE</a></code> condition variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga295d2586aa4d2379248805e622b43742"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MUTEX_CLEANUP</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">mx</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mutex object finalization. </p>
<p>This macro finalizes a mutex object.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763">MUTEX_TYPE</a> lock;</div><div class="line"><a class="code" href="group__group__threads.html#gaebadda8d216cdac28b0d9763be7fe689">MUTEX_SETUP</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648">MUTEX_LOCK</a>(lock);</div><div class="line">... <span class="comment">// critical section</span></div><div class="line"><a class="code" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9">MUTEX_UNLOCK</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga295d2586aa4d2379248805e622b43742">MUTEX_CLEANUP</a>(lock);</div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mx</td><td><code><a class="el" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763" title="Type of a mutex object. ">MUTEX_TYPE</a></code> mutex object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga10ba6c8c4a5e2bcf9f5f5fd41675e122"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MUTEX_INITIALIZER</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mutex initializer object. </p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">static</span> <a class="code" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763">MUTEX_TYPE</a> lock = <a class="code" href="group__group__threads.html#ga10ba6c8c4a5e2bcf9f5f5fd41675e122">MUTEX_INITIALIZER</a>;</div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line">  ... <span class="comment">// some other work to do</span></div><div class="line">  <a class="code" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648">MUTEX_LOCK</a>(lock);</div><div class="line">  ... <span class="comment">// critical section</span></div><div class="line">  <a class="code" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9">MUTEX_UNLOCK</a>(lock);</div><div class="line">  ...</div><div class="line">}</div></div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga4a9fdd824c39252e5bf292df736e5648"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MUTEX_LOCK</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">mx</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mutex object lock. </p>
<p>This macro acquires mutex.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763">MUTEX_TYPE</a> lock;</div><div class="line"><a class="code" href="group__group__threads.html#gaebadda8d216cdac28b0d9763be7fe689">MUTEX_SETUP</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648">MUTEX_LOCK</a>(lock);</div><div class="line">... <span class="comment">// critical section</span></div><div class="line"><a class="code" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9">MUTEX_UNLOCK</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga295d2586aa4d2379248805e622b43742">MUTEX_CLEANUP</a>(lock);</div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mx</td><td><code><a class="el" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763" title="Type of a mutex object. ">MUTEX_TYPE</a></code> mutex object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gaebadda8d216cdac28b0d9763be7fe689"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MUTEX_SETUP</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">mx</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mutex object initialization. </p>
<p>This macro initializes a mutex object.</p>
<p>To declare and initialize static mutex objects, see <code><a class="el" href="group__group__threads.html#ga10ba6c8c4a5e2bcf9f5f5fd41675e122" title="Mutex initializer object. ">MUTEX_INITIALIZER</a></code>.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763">MUTEX_TYPE</a> lock;</div><div class="line"><a class="code" href="group__group__threads.html#gaebadda8d216cdac28b0d9763be7fe689">MUTEX_SETUP</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648">MUTEX_LOCK</a>(lock);</div><div class="line">... <span class="comment">// critical section</span></div><div class="line"><a class="code" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9">MUTEX_UNLOCK</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga295d2586aa4d2379248805e622b43742">MUTEX_CLEANUP</a>(lock);</div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mx</td><td><code><a class="el" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763" title="Type of a mutex object. ">MUTEX_TYPE</a></code> mutex object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga94ada48918e73511c91e3e0e885fe763"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MUTEX_TYPE</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Type of a mutex object. </p>
<p>This macro represents a portable mutex object type.</p>
<p>To declare and initialize static mutex objects, see <code><a class="el" href="group__group__threads.html#ga10ba6c8c4a5e2bcf9f5f5fd41675e122" title="Mutex initializer object. ">MUTEX_INITIALIZER</a></code>.</p>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763">MUTEX_TYPE</a> lock;</div><div class="line"><a class="code" href="group__group__threads.html#gaebadda8d216cdac28b0d9763be7fe689">MUTEX_SETUP</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648">MUTEX_LOCK</a>(lock);</div><div class="line">... <span class="comment">// critical section</span></div><div class="line"><a class="code" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9">MUTEX_UNLOCK</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga295d2586aa4d2379248805e622b43742">MUTEX_CLEANUP</a>(lock);</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms. </dd></dl>

</div>
</div>
<a class="anchor" id="ga706e720f96e7405766dd119e654e03f9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MUTEX_UNLOCK</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">mx</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mutex object unlock. </p>
<p>This macro releases mutex.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763">MUTEX_TYPE</a> lock;</div><div class="line"><a class="code" href="group__group__threads.html#gaebadda8d216cdac28b0d9763be7fe689">MUTEX_SETUP</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga4a9fdd824c39252e5bf292df736e5648">MUTEX_LOCK</a>(lock);</div><div class="line">... <span class="comment">// critical section</span></div><div class="line"><a class="code" href="group__group__threads.html#ga706e720f96e7405766dd119e654e03f9">MUTEX_UNLOCK</a>(lock);</div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga295d2586aa4d2379248805e622b43742">MUTEX_CLEANUP</a>(lock);</div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mx</td><td><code><a class="el" href="group__group__threads.html#ga94ada48918e73511c91e3e0e885fe763" title="Type of a mutex object. ">MUTEX_TYPE</a></code> mutex object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gab0733064c17124af0377d69e91d24430"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_CANCEL</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">tid</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Cancel a thread. </p>
<p>This macro requests that the specified thread be cancelled.</p>
<p>POSIX threads can be cancelled when currently in a cancellation point, which are certain functions that will terminate the thread when the thread is cancelled.</p>
<dl class="section warning"><dt>Warning</dt><dd>Cancelling a thread may lead to resource leaks when the thread has no mechanism to clean up its state (memory allocated, files and sockets opened etc.), unless cleanup handlers are defined for each thread, e.g. with <code>pthread_cleanup_push</code>. Even when defining a cleanup function, care must be taken to prevent resource leaks that may be caused by cancellation points that sit between a resouce acquisition operation and its release operation, e.g. between a file open and close operation some read/write functions may be called that are cancellation points. The gSOAP engine and plugins are designed to maintain the engine state using resource pointers to resources (memory, files, sockets etc.) in the <code><a class="el" href="structsoap.html" title="Context with the engine state. ">soap</a></code> context. The context should be passed to the cleanup function when added with <code>pthread_cleanup_push</code> to cleanup the context. This cleanup function should call <code><a class="el" href="group__group__context.html#gaf7d0176161e9def36981e24faa1913d9" title="Delete all dynamically-allocated C++ objects managed by the specified soap context. ">soap_destroy</a></code>, <code><a class="el" href="group__group__context.html#ga81a009ae1ea825a05e5241e2b7a8ece9" title="Delete all data from heap memory managed by the specified soap context and release the freed memory b...">soap_end</a></code>, and <code><a class="el" href="group__group__context.html#ga57108ca4681186e58b5b189c3528f10a" title="Finalize and free the given soap context from unmanaged heap memory. ">soap_free</a></code> (in that order). However, use <code><a class="el" href="group__group__threads.html#gab0733064c17124af0377d69e91d24430" title="Cancel a thread. ">THREAD_CANCEL</a></code> at your own risk. User-defined service operations and other non-gSOAP code may not meet the requirements to perform a safe <code><a class="el" href="group__group__threads.html#gab0733064c17124af0377d69e91d24430" title="Cancel a thread. ">THREAD_CANCEL</a></code> unless the cleanup functions are carefully designed. Alternatively, a simpler approach with a global flag (a flag per thread) may suffice: set the flag by the main thread to indicate termination is requested of the specific thread and check this flag in the user-defined service operations to terminate the service operation with an error, e.g. <code>return 500</code>.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;soapH.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">struct </span>soap *soap = <a class="code" href="group__group__context.html#ga87c20488b2dc680aaa7689b1d024989c">soap_new</a>();</div><div class="line">soap-&gt;<a class="code" href="structsoap.html#a6b18b017ce2c77ac2b6331469094de59">bind_flags</a> = SO_REUSEADDR;            <span class="comment">// immediate port reuse</span></div><div class="line">soap-&gt;<a class="code" href="structsoap.html#a78199a81c504833047224a0ceff6f906">accept_timeout</a> = 3600;                <span class="comment">// exit loop when no request arrives in one hour</span></div><div class="line">soap-&gt;<a class="code" href="structsoap.html#a711bb3a53de7cc62429e4d3a2e0b5474">send_timeout</a> = soap_recv_timeout = 5; <span class="comment">// 5 seconds max socket stall time (unlimited by default)</span></div><div class="line">soap-&gt;<a class="code" href="structsoap.html#afcf1d236d052579122f785d7639c43c7">transfer_timeout</a> = 30;                <span class="comment">// 30 seconds max message transfer time (unlimited by default)</span></div><div class="line">soap-&gt;<a class="code" href="structsoap.html#a345900c2db67e915ceb02bfa21ecbcbd">recv_maxlength</a> = 1048576;             <span class="comment">// limit messages received to 1MB (2GB by default)</span></div><div class="line"><span class="keywordflow">if</span> (<a class="code" href="group__group__soap.html#gaaae8747f4cdacee575875c3a2488d99c">soap_valid_socket</a>(<a class="code" href="group__group__io.html#ga0a9725a3edbc27b97456190fee47cc18">soap_bind</a>(soap, NULL, PORTNUM, BACKLOG)))</div><div class="line">{</div><div class="line">  <span class="keywordflow">while</span> (1)</div><div class="line">  {</div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group__group__soap.html#gaaae8747f4cdacee575875c3a2488d99c">soap_valid_socket</a>(<a class="code" href="group__group__io.html#gaec0e1aecc2d5479d8099762feb4713c6">soap_accept</a>(soap)))</div><div class="line">    {</div><div class="line">      <a class="code" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a">THREAD_TYPE</a> tid;</div><div class="line">      <span class="keyword">struct </span>soap *tsoap = <a class="code" href="group__group__context.html#gab4c3f8ce80baf0f1fec8c86f0bb5788a">soap_copy</a>(soap);</div><div class="line">      <span class="keywordflow">if</span> (!tsoap)</div><div class="line">        <a class="code" href="group__group__io.html#ga0ca0c64dc76af8617956a62cf117db94">soap_force_closesock</a>(soap);</div><div class="line">      <span class="keywordflow">else</span></div><div class="line">        <span class="keywordflow">while</span> (<a class="code" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486">THREAD_CREATE</a>(&amp;tid, (<span class="keywordtype">void</span>*(*)(<span class="keywordtype">void</span>*))&amp;accept_request, (<span class="keywordtype">void</span>*)tsoap))</div><div class="line">          sleep(1); <span class="comment">// failed, try again</span></div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (soap-&gt;<a class="code" href="structsoap.html#a10b66d6d489690b7d0f591ae2633dd13">errnum</a>) <span class="comment">// accept failed, try again after 1 second</span></div><div class="line">    {</div><div class="line">      <a class="code" href="group__group__fault.html#ga931a4ab6df2553b48a0c270f8a0a88af">soap_print_fault</a>(soap, stderr);</div><div class="line">      sleep(1);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span> <span class="comment">// accept_timeout timed out, quit looping</span></div><div class="line">    {</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div><div class="line">    <a class="code" href="group__group__context.html#gaf7d0176161e9def36981e24faa1913d9">soap_destroy</a>(soap);</div><div class="line">    <a class="code" href="group__group__context.html#ga81a009ae1ea825a05e5241e2b7a8ece9">soap_end</a>(soap);</div><div class="line">  }</div><div class="line">}</div><div class="line"><a class="code" href="group__group__context.html#ga57108ca4681186e58b5b189c3528f10a">soap_free</a>(soap);</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> *accept_request(<span class="keyword">struct</span> soap *soap)</div><div class="line">{</div><div class="line">  <a class="code" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a">THREAD_TYPE</a> tid;</div><div class="line">  <span class="keyword">struct </span>soap *tsoap;</div><div class="line">  <a class="code" href="group__group__threads.html#ga5848fc7adb50b3a15e40955dce7f8f53">THREAD_DETACH</a>(<a class="code" href="group__group__threads.html#ga9ab5a77b8cf2b98f7d6c1b48bb421f69">THREAD_ID</a>);</div><div class="line">  <span class="comment">// create a new thread that is timed to execute for max 10 seconds</span></div><div class="line">  tsoap = <a class="code" href="group__group__context.html#gab4c3f8ce80baf0f1fec8c86f0bb5788a">soap_copy</a>(soap);</div><div class="line">  <span class="keywordflow">if</span> (!tsoap)</div><div class="line">  {</div><div class="line">    <a class="code" href="group__group__io.html#ga0ca0c64dc76af8617956a62cf117db94">soap_force_closesock</a>(soap);</div><div class="line">  }</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">  {</div><div class="line">    <span class="keywordflow">while</span> (<a class="code" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486">THREAD_CREATE</a>(&amp;tid, (<span class="keywordtype">void</span>*(*)(<span class="keywordtype">void</span>*))&amp;process_request, (<span class="keywordtype">void</span>*)tsoap))</div><div class="line">      sleep(1); <span class="comment">// failed, try again</span></div><div class="line">    <span class="comment">// allow serving the request by the new thread for up to 30 seconds max</span></div><div class="line">    sleep(30);</div><div class="line">    <span class="comment">// terminate process_request thread</span></div><div class="line">    <a class="code" href="group__group__threads.html#gab0733064c17124af0377d69e91d24430">THREAD_CANCEL</a>(tid);</div><div class="line">  }</div><div class="line">  <span class="comment">// clean up</span></div><div class="line">  <a class="code" href="group__group__context.html#gaf7d0176161e9def36981e24faa1913d9">soap_destroy</a>(soap);</div><div class="line">  <a class="code" href="group__group__context.html#ga81a009ae1ea825a05e5241e2b7a8ece9">soap_end</a>(soap);</div><div class="line">  <a class="code" href="group__group__context.html#ga57108ca4681186e58b5b189c3528f10a">soap_free</a>(soap);</div><div class="line">  <span class="keywordflow">return</span> NULL;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> *process_request(<span class="keyword">struct</span> soap *soap)</div><div class="line">{</div><div class="line">  <span class="comment">// add the cleanup function</span></div><div class="line">  pthread_cleanup_push((<span class="keywordtype">void</span>(*)(<span class="keywordtype">void</span>*))&amp;cleanup, (<span class="keywordtype">void</span>*)soap);</div><div class="line">  <a class="code" href="group__group__io.html#ga51dba7706a505240bd8935c0b28e419d">soap_serve</a>(soap);</div><div class="line">  <span class="comment">// remove the cleanup function and call it to cleanup the context</span></div><div class="line">  pthread_cleanup_pop(1);</div><div class="line">  <span class="keywordflow">return</span> NULL;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> cleanup(<span class="keyword">struct</span> soap *soap)</div><div class="line">{</div><div class="line">  <a class="code" href="group__group__context.html#gaf7d0176161e9def36981e24faa1913d9">soap_destroy</a>(soap);</div><div class="line">  <a class="code" href="group__group__context.html#ga81a009ae1ea825a05e5241e2b7a8ece9">soap_end</a>(soap);</div><div class="line">  <a class="code" href="group__group__context.html#ga57108ca4681186e58b5b189c3528f10a">soap_free</a>(soap);</div><div class="line">}</div></div><!-- fragment --> <dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tid</td><td><code><a class="el" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a" title="Type of a thread (thread ID) ">THREAD_TYPE</a></code> thread ID to cancel </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga66800af53c229b4024b7d5e36e97eb1a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_CLOSE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">tid</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Close the thread ID handle created by <code><a class="el" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5" title="Create a new joinable thread (Windows only) ">THREAD_CREATEX</a></code> (Windows only) </p>

</div>
</div>
<a class="anchor" id="gabee88cce937a2709b4799ed8df36d486"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_CREATE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">tidptr, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">funcptr, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">argptr&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create a new thread. </p>
<p>This macro creates a new thread and runs the specified function with the argument parameter passed to this function.</p>
<dl class="section warning"><dt>Warning</dt><dd>On Windows platforms <code><a class="el" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486" title="Create a new thread. ">THREAD_CREATE</a></code> uses <code>_beginthread</code> which returns a thread ID handle that cannot be joined. To join a thread use <code><a class="el" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5" title="Create a new joinable thread (Windows only) ">THREAD_CREATEX(&amp;tid, func, arg)</a></code> then <code><a class="el" href="group__group__threads.html#ga6bad18c2ce46fa43f1f4d83c8010a43b" title="Join a thread. ">THREAD_JOIN</a></code>. Don't forget to <code><a class="el" href="group__group__threads.html#ga66800af53c229b4024b7d5e36e97eb1a" title="Close the thread ID handle created by THREAD_CREATEX (Windows only) ">THREAD_CLOSE(tid)</a></code> afterwards: <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a">THREAD_TYPE</a> tid;</div><div class="line"><span class="keywordflow">while</span> (<a class="code" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5">THREAD_CREATEX</a>(&amp;tid, (<span class="keywordtype">void</span>*(*)(<span class="keywordtype">void</span>*))&amp;process_request, (<span class="keywordtype">void</span>*)tsoap)))</div><div class="line">  sleep(1); <span class="comment">// failed, try again</span></div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga6bad18c2ce46fa43f1f4d83c8010a43b">THREAD_JOIN</a>(tid); <span class="comment">// wait for the thread to terminate and join</span></div><div class="line"><a class="code" href="group__group__threads.html#ga66800af53c229b4024b7d5e36e97eb1a">THREAD_CLOSE</a>(tid); <span class="comment">// close handle </span></div><div class="line">... <span class="comment">// some other work to do</span></div></div><!-- fragment --></dd></dl>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a">THREAD_TYPE</a> tid;</div><div class="line"><span class="keywordflow">while</span> (<a class="code" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486">THREAD_CREATE</a>(&amp;tid, (<span class="keywordtype">void</span>*(*)(<span class="keywordtype">void</span>*))&amp;process_request, (<span class="keywordtype">void</span>*)tsoap)))</div><div class="line">  sleep(1); <span class="comment">// failed, try again</span></div><div class="line">... <span class="comment">// some other work to do</span></div><div class="line"><a class="code" href="group__group__threads.html#ga6bad18c2ce46fa43f1f4d83c8010a43b">THREAD_JOIN</a>(tid); <span class="comment">// optional: to wait for the thread to terminate and join (see warning)</span></div><div class="line">... <span class="comment">// some other work to do</span></div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tidptr</td><td>pointer to <code><a class="el" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a" title="Type of a thread (thread ID) ">THREAD_TYPE</a></code> thread ID to assign </td></tr>
    <tr><td class="paramname">funcptr</td><td>function to run by the new thread </td></tr>
    <tr><td class="paramname">argptr</td><td>the argument (a pointer) to pass to the function when called </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero on success and nonzero on failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga45fbba03f3933a43d2ed3819b53ec1c5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_CREATEX</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">tidptr, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">funcptr, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">argptr&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create a new joinable thread (Windows only) </p>
<p>On Windows platforms <code><a class="el" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486" title="Create a new thread. ">THREAD_CREATE</a></code> uses <code>_beginthread</code> which returns a thread ID handle that cannot be joined. To join a thread use <code><a class="el" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5" title="Create a new joinable thread (Windows only) ">THREAD_CREATEX(&amp;tid, func, arg)</a></code> then <code><a class="el" href="group__group__threads.html#ga6bad18c2ce46fa43f1f4d83c8010a43b" title="Join a thread. ">THREAD_JOIN</a></code>. Don't forget to <code><a class="el" href="group__group__threads.html#ga66800af53c229b4024b7d5e36e97eb1a" title="Close the thread ID handle created by THREAD_CREATEX (Windows only) ">THREAD_CLOSE(tid)</a></code> afterwards. </p>

</div>
</div>
<a class="anchor" id="ga5848fc7adb50b3a15e40955dce7f8f53"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_DETACH</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">tid</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Detach a thread. </p>
<p>This macro detaches the specified thread. A detached thread cannot be joined back with the thread that created it. When a detached thread terminates, its resources are automatically released back to the system without the need for another thread to join with the terminated thread.</p>
<p>This macro has no effect on Windows platforms, see <code><a class="el" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486" title="Create a new thread. ">THREAD_CREATE</a></code>.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;plugin/threads.h&quot;</span></div><div class="line"></div><div class="line"><a class="code" href="group__group__threads.html#ga5848fc7adb50b3a15e40955dce7f8f53">THREAD_DETACH</a>(<a class="code" href="group__group__threads.html#ga9ab5a77b8cf2b98f7d6c1b48bb421f69">THREAD_ID</a>); <span class="comment">// detach self</span></div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tid</td><td><code><a class="el" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a" title="Type of a thread (thread ID) ">THREAD_TYPE</a></code> thread ID to detach </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gae6cf42265fe26b84cec6c05b498a7b7c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_EXIT</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Exit the current thread. </p>
<p>This macro terminates the current thread.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms. </dd></dl>

</div>
</div>
<a class="anchor" id="ga9ab5a77b8cf2b98f7d6c1b48bb421f69"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_ID</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The thread ID of self. </p>
<p>This macro represents the current thread ID, i.e. self.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms. </dd></dl>

</div>
</div>
<a class="anchor" id="ga6bad18c2ce46fa43f1f4d83c8010a43b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_JOIN</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">tid</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Join a thread. </p>
<p>This macro waits for the termination of the specified thread to join it.</p>
<p>This macro requires <code><a class="el" href="group__group__threads.html#ga45fbba03f3933a43d2ed3819b53ec1c5" title="Create a new joinable thread (Windows only) ">THREAD_CREATEX</a></code> and <code><a class="el" href="group__group__threads.html#ga66800af53c229b4024b7d5e36e97eb1a" title="Close the thread ID handle created by THREAD_CREATEX (Windows only) ">THREAD_CLOSE</a></code> on Windows plaforms.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tid</td><td><code><a class="el" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a" title="Type of a thread (thread ID) ">THREAD_TYPE</a></code> thread ID to join </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga53ca774b0fc84afe282a5419d2d7239a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define THREAD_TYPE</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Type of a thread (thread ID) </p>
<p>This macro represents a portable thread ID type.</p>
<dl class="section note"><dt>Note</dt><dd>This macro is declared in <em><code>gsoap/plugin/threads.h</code></em> and requires compilation of <em><code>gsoap/plugin/threads.c</code></em> on Windows platforms.</dd></dl>
<dl class="section user"><dt>Example:</dt><dd></dd></dl>
<div class="fragment"><div class="line"><a class="code" href="group__group__threads.html#ga53ca774b0fc84afe282a5419d2d7239a">THREAD_TYPE</a> tid;</div><div class="line"><span class="keywordflow">while</span> (<a class="code" href="group__group__threads.html#gabee88cce937a2709b4799ed8df36d486">THREAD_CREATE</a>(&amp;tid, (<span class="keywordtype">void</span>*(*)(<span class="keywordtype">void</span>*))&amp;process_request, (<span class="keywordtype">void</span>*)tsoap)))</div><div class="line">  sleep(1); <span class="comment">// failed, try again</span></div></div><!-- fragment --> 
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<hr class="footer">
<address class="footer">
Copyright (C) 2021, Robert van Engelen, Genivia Inc., All Rights Reserved.
</address>
<address class="footer"><small>
Converted on Tue Apr 20 2021 19:48:13 by <a target="_blank" href="http://www.doxygen.org/index.html">Doxygen</a> 1.8.11</small></address>
<br>
<div style="height: 246px; background: #DBDBDB;">
</body>
</html>
